package com.flnet.spsys.controller;

import com.flnet.spsys.entity.TbProgrammeDetail;
import com.flnet.spsys.service.ITbProgrammeDetailService;
import com.flnet.spsys.utils.ResultJson;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/programmeDetail")
public class TbProgrammeDetailController extends BaseController{
    @Autowired
    private ITbProgrammeDetailService iTbProgrammeDetailService;


    @ApiOperation(value = "方案详情",notes = "获取方案详情")
    @ApiResponses(
            @ApiResponse(code = 200,message = "获取成功",response = ResultJson.class)
    )
    @ResponseBody
    @CrossOrigin
    @PostMapping("/info")
    public Object showProgrammeInfo(){
        List<TbProgrammeDetail> tbProgrammeDetailList = iTbProgrammeDetailService.list();
        return ResultJson.success(tbProgrammeDetailList);
    }

    @PostMapping("/insert")
    public Object getProgrammeDetailInfo(TbProgrammeDetail tbProgrammeDetail){
        tbProgrammeDetail.setId(3);
        tbProgrammeDetail.setAddress("广东");
        tbProgrammeDetail.setTitle("标题2");
        tbProgrammeDetail.setSinglePrice(12.2);
        tbProgrammeDetail.setProgrammeState("处理");
        tbProgrammeDetail.setRequirement("要求2");
        tbProgrammeDetail.setLastDraftTime(null);

        boolean save = iTbProgrammeDetailService.save(tbProgrammeDetail);
        if(save==false){
            System.out.println("添加失败！");
        }else{
            System.out.println("添加成功！");
        }
        return save;
    }
}
